<template>
	<view class="comeLook">
		<!-- 材料出库---查看记录 组件-->
		<baseInput @inputChange="inputChange" @clearInput="clearInput"></baseInput>
		
		<view class="info">
			<scroll-view class="content-scoll" scroll-y='true' @scrolltolower='scrolltolowerEx'>
				<view class="item" v-for="(item,index) in tableData" :key="index" @click="getInfoItem(item)">
					<view class="header">
						<image class="image" src="/subpackage-equipment/static/project1.png" mode=""></image>
						<view class="box">
							<view class="t1">{{item.orgName}}</view>
							<view class="t2">{{item.projectCascade}}</view>
						</view>
					</view>
					
					<view class="item-body">
						<view class="item-nav">
							<view class="name">出库材料：</view>
							<view class="value">{{item.materialNames}}</view>
						</view>
						<view class="item-nav">
							<view class="name">出库编号：</view>
							<view class="value">{{item.code}}</view>
						</view>
						<view class="item-nav">
							<view class="name">提交时间：</view>
							<view class="value">{{item.recordCreateDatetime}}</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
		
	</view>
</template>

<script>
	import baseInput from "@/components/baseInput/baseInput.vue"
	import { getMaterialOutList } from "@/api/materials/materials.js"
	import mixins from "@/utils/mixins.js"
	export default {
		name: "comeLook",
		mixins: [mixins],
		components: {
			baseInput,
			
		},
		mounted() {
			this.init()
		},
		data() {
			return {
				keyword:"",
				tableData:[],
				pagination:{
					total: "",
					pageSize: 10,
					currentPage: 1,
					totalPage:1,
				},
				flag:false,
			}
		},
		methods: {
			init(){
				this.getList()
			},
			getInfoItem(res){
				uni.navigateTo({
					url: "/subpackage-materials/pages/materials/materialsCome/components/comeInfo",
					success(result) {
						// setTimeout(()=>{
						// 	console.log('emit')
						// 	_this.$$emit('data-check',[1,2,3])
						// },1000)
						result.eventChannel.emit('acceptDataFromOpenerPage', res)
						// console.log('123123')
						// _this.$$emit('data-check',res)
					}
				})
			},
			getList(){
				if(this.flag){
					return
				}
				console.log('total',this.pagination.total)
				if(this.pagination.total !== "" &&  this.tableData.length >0  && this.tableData.length >= this.pagination.total ){
					uni.showToast({
						icon: "none",
						title: "到底了"
					})
					return
				}
				let _data = {
					currPage: this.pagination.currentPage,
					pageSize: this.pagination.pageSize,
					params: {
						code:this.keyword
					}
				}
				getMaterialOutList(_data).then(res=>{
					if(res.success){
						let list  = res.result.list.map(item=>({ ...item, recordCreateDatetime: this.getDate2(item.recordCreateDate)}))
						this.tableData = [...this.tableData, ...list]
						this.pagination.total = res.result.total
					}
				
				})
			},
			inputChange(e){
				if(e){
				this.keyword=e
				}else {
					this.keyword=""
				}
				// clearTimeout(this.time)
				// this.time = setTimeout(()=>{
					this.pagination.currentPage = 1
					this.tableData=[]
					this.getList()
				// },500)
			},
			clearInput(){
				this.keyword=""
				this.pagination.currentPage = 1
				this.tableData=[]
				this.getList()
			},
			scrolltolowerEx() {
				this.pagination.currentPage ++
				this.getList()
			},
		}
	}
</script>

<style lang="scss" scoped>
	.comeLook{
		padding-top: 20rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		.content-scoll{
			height: 65vh;
		}
		.info{
			padding-top: 34rpx;
			.item{
				width: 100%;
				// height: 384rpx;
				background: linear-gradient(180deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
				box-shadow: 0rpx 0rpx 34rpx 2rpx rgba(47, 128, 237, 0.1);
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				padding: 20rpx 35rpx;
				box-sizing: border-box;
				margin-bottom: 36rpx;
				
				.header{
					// height: 144rpx;
					display: flex;
					align-items: center;
					border-bottom: 2rpx solid #E0E7F6;
					.image{
						width: 70rpx;
						height: 70rpx;
						margin-right: 44rpx;
						margin-left: 12rpx;
					}
					.box{
						flex: 1;
						.t1{
							font-size: 32rpx;
							font-weight: bold;
							color: #445469;
							margin-bottom: 10rpx;
						}
						.t2{
							font-size: 28rpx;
							font-weight: 500;
							color: #6A819E;
						}
					}
				}
				.item-body{
					font-size: 28rpx;
					font-weight: 500;
					color: #445469;
					padding-left: 10rpx;
					padding-top: 20rpx;
					.item-nav{
						display: flex;
						margin-top: 22rpx;
						.name{
							width: 140rpx;
						}
						.value{
							width: 360rpx;
							white-space:nowrap;
							overflow:hidden;
							text-overflow:ellipsis;
						}
					}
				}
			}
		}
	}
</style>
